package com.daily.DailyStudy.Shallow2DeepCopy;

public class DeepCopy {

    public static void main(String[] args) {
        Book book = new Book();
        book.setBook_name("水浒传");
        book.setBook_price("20");
        Bookshelf_Deep shelf = new Bookshelf_Deep();
        shelf.setBook(book);
        shelf.setNum(1);
        shelf.setName("长春图书馆");

        Bookshelf_Deep shelf2 = (Bookshelf_Deep)shelf.clone();
        Book book2 = shelf2.getBook();
        book2.setBook_name("老人与海");
        book2.setBook_price("15");
        shelf2.setBook(book2);
        shelf2.setNum(2);
        shelf2.setName("广州图书馆");

        System.out.println("1: "+shelf.toString());
        System.out.println("2: "+shelf2.toString());
    }
}
